<template>
  <div class="edit-padding" style="width: 100%;">
    <v-md-editor v-model="text"
                 height="500px"
                 :disabled-menus="[]"
                 @change="sendMsg()"
                 @upload-image="handleUploadImage"
                 @copy-code-success="handleCopyCodeSuccess"
    />
  </div>
</template>

<script>

export default {
  name: "MDEditor",
  props: ['text'],
  data() {
    return {
    }
  },
  methods: {
    sendMsg () {
      // 自定义事件
      this.$emit('sendText',this.text)
    },

    handleCopyCodeSuccess(code) {
      console.log(code);
    },
    handleUploadImage(event, insertImage, files) {
      // 拿到 files 之后上传到文件服务器，然后向编辑框中插入对应的内容
      console.log(files);

      // 此处即为向编辑框中插入的内容，url即为图片上传后返回的链接
      // 此处只做示例
      insertImage({
        url:
            'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1269952892,3525182336&fm=26&gp=0.jpg',
        desc: '七龙珠',
        // width: 'auto',
        // height: 'auto',
      });
    },
  },

}
</script>

<style scoped>

</style>